package asteroids.model.expressions;

import exceptions.IllegalOperandException;

/**
 * A subclass of expression (E) that represents the lessthan (<) comparison
 * 
 * @version 1.0
 * 
 * @author	Thijs Peirelinck & Wouter Parys
 *
 */
public class LessThan extends DoubleComparison {

	public LessThan(E e1, E e2) {
		super(e1, e2);
	}

	@Override
	public Boolean getValue() {
		if(!this.isValidExpression()) { throw new IllegalOperandException(); }
		return ((Double)getLeftOperand().getValue()) < ((Double)getRightOperand().getValue());
	}
	
	@Override
	public String toString() {
		return getLeftOperand().toString() + " < " + getRightOperand().toString();
	}
	
	@Override
	public LessThan createCopy() {
		return new LessThan(getLeftOperand().createCopy(), getRightOperand().createCopy());
	}
}
